package UIFree.controls
{
	import UIFree.CLoader;
	import UIFree.uif_component;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.system.LoaderContext;

	public class uif_imageButton extends uif_baseButton {
		private var _image: *;
		public function uif_imageButton(parent:uif_component, c_image: *, ax:int=0, ay:int=0, 
										releaseFunc: Function=null, styleClass: String='') {
			function init(): void {
				addChildAt(_image, 0);
				buttonMode = true;
				mouseChildren: false;
			}
			if (c_image is Class) { 
				_image = new c_image();
				init();
			} else {
				if (c_image is String) {
					_image = new CLoader(this, c_image, function(e: Event): void {
						init();
					}, 0, 0, new LoaderContext(true));
				} else {
					_image = c_image;
					init();
				}
			}	
			super(parent, ax, ay, _image.width, _image.height, styleClass);

			if (releaseFunc != null) addEvent(MouseEvent.CLICK, releaseFunc);
			addEvent(MouseEvent.ROLL_OVER, function(e: MouseEvent): void {
				if (enable) fx('light', light, 2).start();
			});

			addEvent(MouseEvent.ROLL_OUT, function(e: MouseEvent): void {
				if (getFX('light')) FXNameCancel('light');
				if (light > 1) fx('light', light, 1).start();
			});
		}
		
		public function get image(): * {
			return  _image;
		}
		
	}
}